package com.ciaojian.store.controller.franchisees;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ciaojian.core.enums.business.WorkerStatusEnum;
import com.ciaojian.core.model.Worker;
import com.ciaojian.core.model.vo.FranchiseesStoreVo;
import com.ciaojian.core.util.Result;
import com.ciaojian.store.service.StoreServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Api(tags = "加盟商门店接口")
@RestController
@RequestMapping("/franchisees/store")
public class FStoreController {
    @Resource
    private StoreServiceImpl storeService;

    @ApiOperation("加盟门店信息")
    @GetMapping("/getStoreInfo")
    public Result getStoreInfo(@RequestParam Integer storeId) {
        return Result.ok(storeService.getFranchiseesStoreInfo(storeId));
    }

    @ApiOperation("编辑门店信息")
    @PostMapping("/updateStoreInfo")
    public Result updateStoreInfo(@RequestBody FranchiseesStoreVo franchiseesStoreVo) {
        return storeService.updateStoreInfo(franchiseesStoreVo);
    }

    @ApiOperation("查看员工")
    @GetMapping("/worker")
    public Result worker(@RequestParam Integer storeId) {
        LambdaQueryWrapper<Worker> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(Worker::getStoreId, storeId)
                .ne(Worker::getStatus, WorkerStatusEnum.outgoing);
        return Result.ok(new Worker().selectList(lambdaQueryWrapper));
    }

}
